<template>
  <el-card class="box-card left" :body-style="{padding:'0 10px'}" shadow="hover" style="height: 260px;">
    <div slot="header" class="clearfix">
      <span style="font-weight: bolder;">{{ $t('route.MyWork') }}</span>
      <!-- v-permission="['work:workflow']" -->
      <el-link
        type="info"
        style="float: right;"
        :underline="false"
        @click="toAllDaiban"
      >{{ $t('buttons.All') }}<i style="margin-left: 5px;" class="el-icon-arrow-right" />
      </el-link>
    </div>
    <el-table :show-header="false" :data="workData">
      <el-table-column :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <a href="javascript:void(0)" @click="handle(scope.row)">
            <span style="color: #FF4949;">[{{ scope.row.procDefName }}]</span>
            <span>{{ scope.row.title }}</span>
          </a>
        </template>
      </el-table-column>
      <el-table-column width="100px" prop="jobtime" />
    </el-table>
  </el-card>
</template>

<script>
import { globals } from '@/utils/request'

export default {
  name: 'MyWork',
  data() {
    return {
      workData: []
    }
  },
  computed: {
    userInfo() {
      return this.$store.state.user.userInfo
    },
    avatar() {
      return this.$store.state.user.avatar
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      getMyWorkByCode().then(res => {
        this.workData = res.data
      })
    },
    openUserInfo() {
      this.$router.push({ path: '/settings/megerMessage' })
    },
    toAllDaiban() {
      const url = globals.workflowPlateformUrl + 'work/todo'
      window.open(url)
    },
    handle(row) {
      console.log(row)
      const processInstanceId = row.processInstanceId
      const executionId = row.executionId
      const processDefinitionId = row.processDefinitionId
      const taskId = row.id
      const mainExecutionId = row.mainExecutionId
      const taskDefinitionKey = row.taskDefinitionKey
      const businessKey = row.businessKey
      let path = ''
      path = '#/approval/approvaldetail?todo=true&approvalNo=' + businessKey + '&id=' + taskId + '&mainExecutionId=' + mainExecutionId + '&taskDefinitionKey=' + taskDefinitionKey + '&processDefinitionId=' + processDefinitionId + '&processInstanceId=' + processInstanceId
      window.open(path, '_blank')
    }
  }
}
</script>
